package com.dj.ms.configure;

import com.dj.ms.event.EventBusHandler;
import com.dj.ms.event.support.EventRetryTaskProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;

/**
 * <br>
 * <p>
 * -
 * </p>
 *
 * <br>
 *
 * @author ZJG
 * @version 1.0
 * @date 2021/10/29 下午6:29
 */
@Order(Ordered.HIGHEST_PRECEDENCE - 200)
@Configuration
public class EventBusAutoConfiguration {

    @Bean("eventBusConfiguration")
    @Order(Ordered.HIGHEST_PRECEDENCE - 200)
    @ConditionalOnMissingBean(EventBusConfiguration.class)
    public EventBusConfiguration eventBusConfiguration(){
        return new EventBusConfiguration();
    }

    @Bean("eventRetryTaskProperties")
    @Order(Ordered.HIGHEST_PRECEDENCE - 600)
    @ConditionalOnMissingBean(EventRetryTaskProperties.class)
    public EventRetryTaskProperties eventRetryTaskProperties() {
        return new EventRetryTaskProperties();
    }

    @Bean("eventBusHandler")
    @Order(Ordered.HIGHEST_PRECEDENCE - 1000)
    @ConditionalOnMissingBean(EventBusHandler.class)
    public EventBusHandler eventBusHandler() {
        return new EventBusHandler();
    }

}
